#include "typedef.h"
u8 *videoram = (unsigned char *) 0x000b8000;

static u32 index = 0;

#define H 25
#define W 80

u8 x,y;

u8 attrib = 0x07;

void vga_curset();
void vga_curget();
void vga_scroll(u8 lines);

void vga_putc(u8 c)
{
  vga_curset();
  if(c == '\n')
  {
    x = 0;
    y +=1;
  }
  else
  {
    videoram[index] = c;
    videoram[index+1] = attrib;
    index += 2;
  }
  vga_curget();
}

void vga_write(u8 *c)
{
  vga_curset();
  while(*c)
  {
    if(c == '\n')
    {
      x = 0;
      y +=1;
    }
    else
    {
      videoram[index] = c;
      videoram[index+1] = attrib;
      index += 2;
    }
  }
  vga_curget();
}
void vga_scroll(u8 lines)
{
  
}
void vga_curset()
{
  x = x % W;
  y = y % H;
  index = (y*W+x)*2;
}
void vga_curget()
{
  x = (index/2) % W;
  y = ((index/2) - x)/W; 
}


